package com.tb.utils;

import com.tb.pojo.User;

import java.io.Serializable;

public class MsgUser implements Serializable {

    /**
     * 状态码
     * 0:接口正常
     * 1:接口异常
     */
    private Integer code=0;
    /**
     * 接口异常提示信息
     */

    private Object user;
    private String msg;
    /**
     * 接口返回数据全部封装在data里
     */

    private Object data;


    /**
     * 接口正常返回
     * @param obj 返回数据
     * @return msg对象
     */
    public static MsgUser success(Object objs,Object obj){
        MsgUser m=new MsgUser();
        m.code=0;
        m.msg="";
        m.user=objs;
        m.data= obj;
        return m;
    }

    /**
     * 接口异常
     * @param code 状态码
     * @param msg 异常信息
     * @return msg
     */
    public static MsgUser error(Integer code,String msg){
        MsgUser m=new MsgUser();
        m.code=code;
        m.msg=msg;
        return m;
    }

    @Override
    public String toString() {
        return "Msg{" +
                "code=" + code +
                ", msg='" + msg + '\'' +
                ", data=" + data +
                '}';
    }

    public Integer getCode() {
        return code;
    }

    public Object getData() {
        return data;
    }

    public String getMsg() {
        return msg;
    }

    public Object getUser() {
        return user;
    }

    public void setUser(Object user) {
        this.user = user;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

}
